<template>
  <div>
    <div>{{ userId }}</div>
    <div>{{ sessionId }}</div>
  </div>
</template>

<script>
import axios from "axios";
export default {
  name: "UserLogin",
  data() {
    return {
      userId: "",
      sessionId: "",
    };
  },
  methods: {
    getUserInfo() {
      // var data = {
      //   phone: "13546795276",
      //   pwd: "acs123acs",
      // };
      // axios.post("api/small/user/v1/register", data).then((res) => {
      //   console.log(res, "注册结果");
      // });
      var data = {
        phone: "13546795276",
        pwd: "acs123acs",
      };
      axios.post("api/small/user/v1/login", data).then((res) => {
        console.log(res);
        this.userId = res.data.result.userId;
        this.sessionId = res.data.result.sessionId;
        console.log(this.userId, this.sessionId);
        this.$store.commit("getUserId", this.userId);
        this.$store.commit("getSessionId", this.sessionId);
        console.log(this.$store.state.userId, this.$store.state.sessionId);
      });
    },
  },
  mounted() {
    this.getUserInfo();
  },
};
</script>

<style scoped></style>
